package com.tarim.streetdance.service.impl;

import com.tarim.streetdance.mapper.CollegeMapper;
import com.tarim.streetdance.model.College;
import com.tarim.streetdance.service.CollegeService;
import com.tarim.streetdance.vo.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CollegeServiceImpl implements CollegeService {
    @Autowired
    private CollegeMapper collegeMapper;

    @Override
    public int updateByPrimaryKeySelective(College college) {
        return collegeMapper.updateByPrimaryKeySelective(college);
    }

    @Override
    public List<College> selectAll(College college) {
        return collegeMapper.selectAll(college);
    }

    @Override
    public PageBean<College> selectForPage(College college, PageBean<College> pageBean) {
        college.addExtField("pageIndex", pageBean.getPageIndex() * pageBean.getPageSize());
        college.addExtField("pageSize", pageBean.getPageSize());
        List<College> list = collegeMapper.selectForPage(college);
        Long count = collegeMapper.selectForPageCount(college);
        pageBean.setData(list.toArray());
        pageBean.setTotalCount(count);
        return pageBean;
    }
}
